/*
 * @Descripttion: 
 * @Author: chendingfengmail@163.com
 * @version: 
 * @Date: 2021-04-07 08:21:18
 * @LastEditors: chendingfengmail@163.com
 * @LastEditTime: 2021-04-12 09:33:17
 */
export default {
  namespaced: true,
  state: {
    // 用户信息
    info: {},
  },
  actions: {
    /**
     * @description 设置用户数据
     * @param {Object} context
     * @param {*} info info
     */
    async set({state, dispatch}, info) {
      // store 赋值
      state.info = info
      // 持久化
      await dispatch('ddAdmin/db/set', {
        dbName: 'sys',
        path: 'user.info',
        value: info,
        user: true
      }, {root: true})
    },
    /**
     * @description 从数据库取用户数据
     * @param {Object} context
     */
    async load({state, dispatch}) {
      // store 赋值
      state.info = await dispatch('ddAdmin/db/get', {
        dbName: 'sys',
        path: 'user.info',
        defaultValue: {},
        user: true
      }, {root: true})
    }
  }
}
